home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Family Forum 259
/
IND_GIANT.BIN
/
Xtras
/
Animation Wizard.dir
/
00007_Script_RadioButton
< prev
next >
Wrap
Text File
|
1997-05-10
|
2KB
|
88 lines
-- RadioButton Script
property ichCurrent -- keeps track of the channel number of the user's current choice
property ichStart -- the channel number of the first answer
property inChannels -- the number of possible answers (channels)
property iRightAnswer -- the correct answer (if there is one, or zero if not specified)
on birth me, startCh, nChannels, rightAnswer, defaultAnswer
set ichStart = startCh
set inChannels = nChannels
repeat with ch = ichStart to (ichStart + inChannels - 1)
puppetSprite ch, TRUE
end repeat
-- If no right answer was specified, set iRightAnswer to 0, so we can check later
if voidP(rightAnswer) then
set iRightAnswer = 0
else
set iRightAnswer = rightAnswer
end if
-- Check for a default value specification
if voidP(defaultAnswer) then
set ichCurrent = 0
else
if defaultAnswer = 0 then
set ichCurrent = 0
else
set ichCurrent = ichStart + defaultAnswer - 1
set the castNum of sprite ichCurrent = the castNum of sprite ichCurrent + 1
updateStage
end if
end if
return me
end birth
on mHit me
set newCh = the clickOn
if ichCurrent <> 0 then
if newCh = ichCurrent then
return -- clicked on the already down button
end if
-- Change the current Down button to the Up version
-- Since this is the Down button, subtract one to get to the Up button
set the castnum of sprite ichCurrent = (the castnum of sprite ichCurrent) - 1
end if
set ichCurrent = newCh
-- Since this is the Up button, add one to get to the Down button
set the castNum of sprite ichCurrent = (the castNum of sprite ichCurrent) + 1
updateStage
end mHit
-- Return the value of the button hit (0 means no answer)
on mGetChosenAnswer me
if ichCurrent = 0 then
return 0
else
return (ichCurrent - ichStart + 1)
end if
end mGetChosenAnswer
on mEvaluate me
if iRightAnswer = 0 then
alert("Attempting to evaluate, but a correct was not given at initialization")
return FALSE
end if
set currentAnswer = mGetChosenAnswer(me)
if currentAnswer = iRightAnswer then
return TRUE
else
return FALSE
end if
end mEvaluate
on mCleanUp me
repeat with ch = ichStart to (ichStart + inChannels)
puppetSprite ch, FALSE
end repeat
end mCleanup